<?php
 require_once "config.php";
 $memberobj=new Member();
 if(isset($_POST["submit"]))
 {
        $en_key = '&56TCVH%#*P*W&vddbsd&^%';
        $enc = new Encryption;
        $loginerrorarr=array();
        if(empty($_POST["username"]) || $_POST["username"]=="username")
        {
            $loginerrorarr["invalidup"]=" Invalid logins. Please try again or create new account";
        }
        if(empty($_POST["password"])|| $_POST["password"]=="password")
        {
            $loginerrorarr["invalidup"]=" Invalid logins. Please try again or create new account";
        }

        if(!$loginerrorarr)
        {
            $member=$memberobj->member_login_validate($_POST["username"],str_replace("'", "''",$enc->encrypt($en_key, $_POST["password"])));
       //     print_r($member);
                    if($member)
                    {
                        $_SESSION['member_id'] = $member['member_id'];
                        $_SESSION['first_name'] = $member['first_name'];
                        $_SESSION['last_name'] = $member['last_name'];
                        $_SESSION['member_email'] = $member['member_email'];
                        $_SESSION['contact_number'] = $member['contact_number'];
                        $_SESSION['pending_credit'] = $member['pending_credit'];
                    }
                else
                     {

                        $loginerrorarr["invalidup"]=" Invalid logins. Please try again or create new account";

                     }


        }
       

 }
?>

<div id="header">
        <div class="headerRight">
           <?php  if(!isset($_SESSION["member_email"])): ?>
            <form action="<? $_SERVER["PHP_SELF"]; ?>" method="post" name="member_login">
            <div class="username"><input name="username" class="usernametxtbox" type="text" value="username" onfocus="if (this.value == 'username') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'username'; }" /></div>
            <div class="password"><input  name="password" class="passwordtxtbox" type="password" value="password" onfocus="if (this.value == 'password') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'password'; }" /></div>
            <div class="login"><input class="logmein" name="submit" type="submit" value="" /></div>
            
			<div class="sociallinks"><a href="#"><img src="images/twt.png" alt="Tweet about Hotel with Offers" /></a><a href="#"><img src="images/fb.png" alt="Share Hotel with Offers on Facebook" /></a><a href="#"><img src="images/ln.png" alt="Connect Hotel with Offers with LinkedIn" /></a></div>
			<br class="clear">
<?php if(isset($loginerrorarr["invalidup"])):?>
            <span class="loginError"><?php echo $loginerrorarr["invalidup"]?> </span>
            <?php endif;?>
            <span class="account"><a href="sign-up.php">No Account? Register Now!</a></span>
            </form>
         <?php else:?>
            <div class="sociallinks"><a href="#"><img src="images/twt.png" alt="Tweet about Hotel with Offers" /></a><a href="#"><img src="images/fb.png" alt="Share Hotel with Offers on Facebook" /></a><a href="#"><img src="images/ln.png" alt="Connect Hotel with Offers with LinkedIn" /></a></div>
            <span class="account">Welcome <?php echo $_SESSION["first_name"]." ".$_SESSION["last_name"];?></span><br>
              <span class="account"><a href="edit_profile.php?id=<?php echo $_SESSION["member_id"];?>">Edit Profile</a></span> |
              <span class="account"><a href="share_url.php">See Share Url</a></span> |
              <span class="account"><a href="my_orders.php">My Orders</a></span> |
              <span class="account"><a href="member_logout.php">logout</a></span>
         <?php endif;?>
            <div class="clear"></div>
        </div>
        <div class="logo"><a href="http://hotelswithoffers.com"><img src="images/logo.png" alt="Hotels with Offers" width="255" height="81" border="0" /></a></div>
        <div class="clear"></div>
    </div>
